class UsersController < ApplicationController

  layout 'main_layout'

  def new
    @user = User.new
    render :template => 'users/register'
  end

  def create
    errors = Array.new
    @user = User.new(params[:user])
 
    if @user.save
      redirect_to home_path
    else
      @user.errors.each do |e|
        errors += [e[1].to_s]
      end
      @user.password = ""
      @user.password_check = ""
      params[:password_check] = ""
        
      flash[:fail] = errors
      render :template => 'users/register'
    end

  end

  def index
    if params[:view]
      @user = User.find_by_summoner_name( params[:view] )
    else
      @users = User.find(:all)
    end
  end

end
